﻿@using ElingOA6_Admin_DSJCJ.Common
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(
        new StyleSheet { ExtensionType = ExtensionType.ListBox }
    )
    @Html.DevExpress().GetScripts(
         new Script { ExtensionType = ExtensionType.ListBox }
    )
      <script>
          if (top.boardtop) {
              top.boardtop.head_txt.innerText = "密码修改";
          }
    </script>
    <script type="text/javascript">
        $(function () {
            var message = $('#hidMessage').val();
            if (message != "") {
                alert(message);
            }

        });

        //提示填写密码
        function OnPasswordValidation(s, e) {
            if (e.value == null || ASPxClientUtils.Trim(String(e.value)) == "") {
                e.isValid = false;
                e.errorText = "请填写密码";
            }
        }

        //提示填写新密码
        function OnNewPasswordValidation(s, e) {
            if (e.value == null || String(e.value) == "") {
                e.isValid = false;
                e.errorText = "请填写新密码";
            }
        }
        //提示填写新密码确认
        function OnNewPasswordTwoValidation(s, e) {
            if (e.value == null || String(e.value) == "") {
                e.isValid = false;
                e.errorText = "请填写新密码确认";
            } else {
                //提示填写新密码确认和新密码不一致
                var newPassword = $.trim(tbNewPassword.GetValue());
                if (newPassword != "") {
                    var newPasswordTwo = $.trim(tbNewPasswordTwo.GetValue());
                    if (newPasswordTwo != newPassword) {
                        e.isValid = false;
                        e.errorText = "新密码确认和新密码不一致";
                    }
                }
            }
        }

        //点击确定按钮后验证原密码
        function ok() {
            if (pd()) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Password/ExitstByPassword',
                    data: { password: tbPassword.GetValue() },
                    success: function (result) {
                        if (result == "Y") {
                            form1.submit();
                        } else {
                            tbPassword.SetErrorText("原密码错误");
                            tbPassword.SetIsValid(false);
                        }
                    }
                });
            }
        }

        //点击确定按钮后验证填写的2次密码是否一致
        function pd() {
            var bl = true;
            var password = tbPassword.GetValue();
            if (password == null || ASPxClientUtils.Trim(password) == "") {
                tbPassword.SetErrorText("请填写密码");
                tbPassword.SetIsValid(false);
                bl = false;
            }

            var newPassword = tbNewPassword.GetValue();
            if (newPassword == null || ASPxClientUtils.Trim(newPassword) == "") {
                tbNewPassword.SetErrorText("请填写新密码");
                tbNewPassword.SetIsValid(false);
                bl = false;
            }

            var newPasswordTwo = tbNewPasswordTwo.GetValue();
            if (newPasswordTwo == null || ASPxClientUtils.Trim(newPasswordTwo) == "") {
                tbNewPasswordTwo.SetErrorText("请填写新密码确认");
                tbNewPasswordTwo.SetIsValid(false);
                bl = false;
            } else {
                if (newPassword != null && ASPxClientUtils.Trim(newPassword) != "") {
                    newPassword = ASPxClientUtils.Trim(newPassword);
                    newPasswordTwo = ASPxClientUtils.Trim(newPasswordTwo);
                    if (newPasswordTwo != newPassword) {
                        tbNewPasswordTwo.SetErrorText("您的新密码确认和新密码不一致,请重新填写！");
                        tbNewPasswordTwo.SetIsValid(false);
                        bl = false;
                    }
                }
            }


            return bl;
        }
        /*取消*/
        function cancel() {
            window.top.location.href = rootPath + "/Index";
        }
    </script>

</head>
<body>
    @using (Html.BeginForm("EditPassword", "Password", FormMethod.Post, new { id = "form1", @class = "tableFrom" }))
    {
        <table align="center" class="tableForm">
            <tr>
                <th>
                    用户名:</th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
                    {
                        settings.Name = "tbLogId";
                        settings.Width = 150;
                        settings.Text = @OperateSession.get(GlobalConstant.PARAM_LOGINID);
                        settings.Enabled = false;
                    }).GetHtml()</td>
            </tr>
            <tr>
                <th>
                    密码:</th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
                    {
                        settings.Name = "tbPassword";
                        settings.Width = 150;
                        settings.Properties.Password = true;
                        settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                        settings.Properties.ValidationSettings.EnableCustomValidation = true;

                    }).GetHtml()</td>
            </tr>
            <tr>
                <th>
                    新密码:</th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
                    {
                        settings.Name = "tbNewPassword";
                        settings.Width = 150;
                        settings.Properties.Password = true;
                        settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                        settings.Properties.ValidationSettings.EnableCustomValidation = true;
                    }).GetHtml()</td>
            </tr>
            <tr>
                <th>
                    新密码确认:</th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
                    {
                        settings.Name = "tbNewPasswordTwo";
                        settings.Width = 150;
                        settings.Properties.Password = true;
                        settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                        settings.Properties.ValidationSettings.EnableCustomValidation = true;
                    }).GetHtml()</td>
            </tr>
            <tr>
            <td></td>
               
                <td >
                 @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnOK";
                   settings.Text = "确定";
                   settings.ControlStyle.CssClass = "button";
                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                   settings.ClientSideEvents.Click = "ok";
               }).GetHtml()
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnCancel";
                   settings.Text = "取消";
                   settings.ControlStyle.CssClass = "button";
                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                   settings.CausesValidation = false;
                   settings.ClientSideEvents.Click = "cancel";

               }).GetHtml()
                </td>
            </tr>
        </table>

    }
</body>
@Html.Hidden("hidMessage", (ViewData["message"]))
</html>
